package demo.rabbitmq.javaapi.simple;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
     * @description description
     * @author zhouxinghuai
     * @date 2018-10-28
     */
    public class MyProducer {

        private final static String EXCHANGE_NAME = "SIMPLE_EXCHANGE";

        public static void main(String[] args) throws IOException, TimeoutException {
            ConnectionFactory factory = new ConnectionFactory();
            factory.setHost("192.168.5.128");
            factory.setPort(5672);
            factory.setVirtualHost("/");
            factory.setUsername("guest");
            factory.setPassword("guest");

            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();

            String msg = "Hello World, Rabbit Mq";
            channel.basicPublish(EXCHANGE_NAME, "gupao.best", null, msg.getBytes());
            channel.close();
            connection.close();
        }

    }

